<template>
	<view class="seach-box">
		<view class="seach-list">
			<view class="seach-left">
				<radio :checked="goolistobj.goods_state" color="#C00000" v-if="ishow" @click="haodozhuant"></radio>
				<image class="img" :src="goolistobj.goods_small_logo"/>
			</view>
			<view class="seach-hezi">
				<view class="seach-name">{{goolistobj.goods_name}}</view>
				<view class="seac-bjq">
					<view class="seach-prcie">{{goolistobj.goods_price | RMBformat }}</view>
					<uni-number-box @change="hdobjqchange" @blur="shijiao" :value="goolistobj.goods_count" :min="1" v-if="ishow"/>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"my-goods",
		props:{
			goolistobj:{
				type:Object,
				default:{}
			},
			ishow:{
				type:Boolean,
				default:false
			}
		},
		data() {
			return {
			};
		},
		methods:{
			//步进器数组变化就执行
			hdobjqchange(value){
				this.goolistobj.goods_count = value
				this.$store.commit('addnumbo',this.goolistobj)
			},
			//步进器失焦事件
			shijiao(event){
				let value = parseInt(event.detail.value)
				if(!value){
					event.detail.value = 1
					return
				}
				if(!Number(event.detail.value)){
					event.detail.value = this.goolistobj.goods_count
					return
				}
				this.goolistobj.goods_count = event.detail.value
				this.$store.commit('addnumbo',this.goolistobj)
			},
			//更改选中状态
			haodozhuant(){
				this.goolistobj.goods_state = !this.goolistobj.goods_state
				this.$store.commit('addxuanzh',this.goolistobj)
			}
		}
	}
</script>

<style lang="scss" scoped>
.seach-box{
	box-sizing: border-box;
	padding: 0 10px;
	.seach-list{
		display: flex;
		padding: 10px 0;
		border-bottom: 1px solid #cccccc;
		padding-bottom: 10px;
		.seach-left{
			display: flex;
			align-items: center;
			.img{
				width: 100px;
				height: 100px;
				display: block;
				border-radius: 5px;
			}
		}
		.seach-hezi{
			margin-left: 10px;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			.seach-name{
				font-size: 13px;
			}
			.seac-bjq{
				display: flex;
				justify-content: space-between;
				.seach-prcie{
					color: #DD524D;
				}
			}
		}
	}
}
</style>
